<?php
ob_start();
session_start ();
include_once 'header.php';
if (! isset ( $_SESSION ['nenunnanu_admin'] )) {
	header ( "location:admin_login.php" );
}
include_once('php/connection.php');
$query = "SELECT * FROM places WHERE parentid = 0";
$rs = mysql_query($query);
if (isset ( $_GET ['status'] ) && $_GET ['status'] == 'success') {
	?>
<center>Add another..
<?
}
if(isset($_POST['add_place']))
{
	if($_POST['add_place'] == 'add' && $_POST['dist'] != '')
	{
		$list = explode(',',$_POST['areas']);
		 $distid = $_POST['dist'];
		echo "".count($list).' records inserted successfuly';
		foreach($list as $area)
		{
		$area = trim($area);
		$ins_query = "INSERT INTO places(parentid,place) values($distid,'$area')";
		mysql_query($ins_query);
		}
	}
}
?>
<table align="center" width="430">
	<form method="post" action=""><input type="hidden"
		name="type" value="quote" />
	
	
	<tr>
		<td>Select District</td>
		<td>
				<select name="dist">
					<option value="">- Select One -</option>
					<?php
						while($row = mysql_fetch_array($rs))
						{
							echo "<option value='$row[id]'>".$row['place']."</option>";
						}
					?>
				</select>
		</td>
	</tr>
	<tr>
		<td>Enter Areas</td>
		<td>
				<textarea cols='30' rows='8' name="areas" ></textarea>
		</td>
	</tr>
	<tr>
		<td></td>
		<td><input type="submit" name="add_place" value="add" /></td>
	</tr>
	</form>
</table>
</body>
</html>